<template>
  <div class="goodtabcontrol">
    <van-tabs @click="toggle" v-model="active">
      <van-tab  v-for="item in datas" :key="item.id" :title="item.text"></van-tab>
    </van-tabs>
  </div>
</template>

<script>
export default {
  name: "GoodTabControl",
  data() {
    return {
      // active只能是数字类型的
      active: Number(this.$route.query.categrayId)
    };
  },
  watch:{
    active(){
      this.$router.replace({
        path:'/tab',
        query:{
          categrayId:this.active
        }
      })
    }
  },
  computed: {
    
  },
  props: {
    datas: {
      type: Array
    }
  },
  methods:{
    toggle(){
      
      this.$bus.$emit('toggle',this.active+1)
      console.log(111);
      window.scrollTo(0,0)
      
      
    }
  },
  created() {
    
  }
};
</script>

<style lang="less" scoped>
</style>